**********************************************************************************************************
**********************************************************************************************************
**********************************************************************************************************
* Do-file for the paper
* Spillover effects of reminder nudges in complex environments
* by Alexander K. Koch, Dan Mønster, and Julia Nafziger
**********************************************************************************************************
**********************************************************************************************************
**********************************************************************************************************

/*
In the following, we provide the Stata codes to generate the data file "Replicationdata" based on the raw data files "Game_data" and "Survey_data". 
*/

*Set the following path: 
global path "SET YOUR PATH HERE" // e.g. global path "C:\Documents\Replicationfiles\"

*Input contains the data set, all outputs will be stored in the output folder.
global rawdata "$path\Rawdata"
global input "$path\Input"
global output "$path\Output"
global temp "$path\Temp"

cd "$rawdata"

use Game_data,clear

********************************************************
** Create tags and indicator variables
********************************************************
*tag one observation per user and recipe
egen tagrecipe=tag(pid r)
*tag one observation per user and level (do this way, because 13th row does not always exist for a recipe and imbalance can occur with tag command)
egen taglevel=tag(pid level)
*tag one observation per user and module
egen tagmodule=tag(pid module_id)
*tag one observation per user
egen taguser=tag(pid)





********************************************************
** Create variables for IFSAs 
********************************************************


*Variable labels
lab var handsbeginning  	"Washing hands in the beginning"
lab var handsafterveg		"Washing hands after handling vegetable"
lab var handsaftermeat		"Washing hands after handling meat"
lab var rinseveg 			"Rinsing vegetable"
lab var notrinsemeat		"Not rinsing raw meat"
lab var knifeafterveg 		"Cleaning knife after handling vegetable"
lab var boardafterveg 		"Cleaning cutting board after handling vegetable"
lab var knifeaftermeat 		"Cleaning knife after handling meat"
lab var boardaftermeat 		"Cleaning cutting board after handling meat"
lab var worktopafterveg 	"Cleaning the worktop after handling vegetable"
lab var worktopaftermeat	"Cleaning the worktop after handling meat"
lab var worktopafterveg_2 	"Cleaning the worktop after handling vegetable (>=2 surfaces cleaned)"
lab var worktopaftermeat_2	"Cleaning the worktop after handling meat  (>=2 surfaces cleaned)"
lab var worktopafterveg_3 	"Cleaning the worktop after handling vegetable (3 surfaces cleaned)"
lab var worktopaftermeat_3	"Cleaning the worktop after handling meat  (3 surfaces cleaned)"

lab var checktemperature 	"Checking the temperature of the meat"
lab var withintime 			"Completed recipe within time limit"
lab var bread 				"Picked up dropped bread"


*IFSA score 
gen ifsa_score=.
replace ifsa_score=handsbeginning+handsafterveg+handsaftermeat+knifeafterveg+boardafterveg+knifeaftermeat+boardaftermeat + worktopafterveg  + worktopaftermeat +checktemperature+rinseveg+notrinsemeat+bread if tagrecipe==1 & Breaddrops==1
replace ifsa_score=handsbeginning+handsafterveg+handsaftermeat+knifeafterveg+boardafterveg+knifeaftermeat+boardaftermeat + worktopafterveg  + worktopaftermeat +checktemperature+rinseveg+notrinsemeat if tagrecipe==1 & Breaddrops==0

*IFSA score for reminded actions in treatment Reminder (hand washing)
gen ifsa_remind=handsbeginning+handsafterveg+handsaftermeat if tagrecipe==1
*Non-reminded actions in treatment Reminder (all IFSAs except hand washing)
gen ifsa_not_remind=ifsa_score-ifsa_remind if tagrecipe==1

*IFSA score for reminded actions in treatment ManyReminders (hand washing, cleaning worktop after handling meat and after handling vegetable, and checking doneness with thermometer)
gen ifsa_many_remind=ifsa_remind+ worktopafterveg  + worktopaftermeat +checktemperature if tagrecipe==1

*IFSA score for never reminded actions (All IFSAs except hand washing, surface cleaning, and thermometer)
gen ifsa_never_remind=ifsa_score-ifsa_many_remind if tagrecipe==1

lab var ifsa_score       	"IFSA score (All actions)"
lab var ifsa_remind         "IFSA score (reminded actions in Reminder)"
lab var ifsa_not_remind     "IFSA score (non-reminded actions in Reminder)"
lab var ifsa_many_remind    "IFSA score (reminded actions in ManyReminders)"
lab var ifsa_never_remind   "IFSA score (never reminded actions in Reminder)"

*Generate the pre-treatment average of ifsa_scores over recipes 1-7; 
*note that because of data issues on the server we lost some individual rows in a few cases (e.g. 3 rows for recipe 1)
*All in all, two participant have only 6 pre-treatment recipes with data 
*Hence, divide by the actual number of recipes with data
bysort pid: egen temp=total(ifsa_score) if level<8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score) if level<8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen pretreatscore=max(temp)
drop temp*

*Alternative outcome measures for robustness checks: >= 2 or =3 areas of the surface cleaned
gen ifsa_score_rob2=.
replace ifsa_score_rob2=handsbeginning+handsafterveg+handsaftermeat+knifeafterveg+boardafterveg+knifeaftermeat+boardaftermeat + worktopafterveg_2  + worktopaftermeat_2 +checktemperature+rinseveg+notrinsemeat+bread if tagrecipe==1 & Breaddrops==1
replace ifsa_score_rob2=handsbeginning+handsafterveg+handsaftermeat+knifeafterveg+boardafterveg+knifeaftermeat+boardaftermeat + worktopafterveg_2  + worktopaftermeat_2 +checktemperature+rinseveg+notrinsemeat if tagrecipe==1 & Breaddrops==0

gen ifsa_score_rob3=.
replace ifsa_score_rob3=handsbeginning+handsafterveg+handsaftermeat+knifeafterveg+boardafterveg+knifeaftermeat+boardaftermeat + worktopafterveg_3  + worktopaftermeat_3 +checktemperature+rinseveg+notrinsemeat+bread if tagrecipe==1 & Breaddrops==1
replace ifsa_score_rob3=handsbeginning+handsafterveg+handsaftermeat+knifeafterveg+boardafterveg+knifeaftermeat+boardaftermeat + worktopafterveg_3  + worktopaftermeat_3 +checktemperature+rinseveg+notrinsemeat if tagrecipe==1 & Breaddrops==0

bysort pid: egen temp=total(ifsa_score_rob2) if level<8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score_rob2) if level<8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen pretreatscore_rob2=max(temp)
drop temp*
bysort pid: egen temp=total(ifsa_score_rob3) if level<8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score_rob2) if level<8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen pretreatscore_rob3=max(temp)
drop temp*


********************************************************
** Create average IFSA score per recipe in a game module
********************************************************
*note that because of data issues on the server we lost some individual rows in a few cases 
*All in all, four participant have only 2 out of 3 recipes with data in module 1
*Hence, divide by the actual number of recipes with data
bysort pid: egen temp=total(ifsa_score) if level<4 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score) if level<4 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module1Score=max(temp)
drop temp*

*note that because of data issues on the server we lost some individual rows in a few cases 
*All in all, two participant have only 3 out of 4 recipes with data module 2
*Hence, divide by the actual number of recipes with data
bysort pid: egen temp=total(ifsa_score) if level>3 & level<8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score) if level>3 & level<8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module2Score=max(temp)
drop temp*

*Scorediff12: Difference in the average score per recipe in game modules 2 and 1; used as a control variable
gen Scorediff12=Module2Score-Module1Score


**Average IFSA score per recipe, using the first 4 recipes (i.e., the first level) of game modules 3 and 4, respectively
*note that because of data issues on the server we lost some individual rows in a few cases 
*All in all, one participant had only 3 out of 4 recipes with data in the first four recipes of module 3
*Hence, divide by the actual number of recipes with data
bysort pid: egen temp=total(ifsa_score) if level==8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score) if level==8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module3Score4r=max(temp)
drop temp*

*note that because of data issues on the server we lost some individual rows in a few cases 
*All participants had 4 out of 4 recipes with data in the first four recipes of module 4
*Hence, divide by the actual number of recipes with data
bysort pid: egen temp=total(ifsa_score) if level==11 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score) if level==11 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module4Score4r=max(temp)
drop temp*


bysort pid: egen temp=total(ifsa_remind) if level==8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_remind) if level==8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module3_Remindedscore4r=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_remind) if level==11 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_remind) if level==11 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module4_Remindedscore4r=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_not_remind) if level==8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_not_remind) if level==8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module3_NonRemindedscore4r=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_not_remind) if level==11 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_not_remind) if level==11 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module4_NonRemindedscore4r=max(temp)
drop temp*


bysort pid: egen temp=total(ifsa_many_remind) if level==8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_many_remind) if level==8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module3_ManyRemindedscore4r=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_many_remind) if level==11 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_many_remind) if level==11 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module4_ManyRemindedscore4r=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_never_remind) if level==8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_never_remind) if level==8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module3_NeverRemindedscore4r=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_never_remind) if level==11 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_never_remind) if level==11 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module4_NeverRemindedscore4r=max(temp)
drop temp*

*For robustness checks - Module Scores: Average IFSA score per recipe in game modules using 2/3 areas of surface cleaned
bysort pid: egen temp=total(ifsa_score_rob2) if level<4 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score_rob2) if level<4 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module1Score_rob2=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_score_rob3) if level<4 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score_rob3) if level<4 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module1Score_rob3=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_score_rob2) if level>3 & level<8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score_rob2) if level>3 & level<8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module2Score_rob2=max(temp)
drop temp*

bysort pid: egen temp=total(ifsa_score_rob3) if level>3 & level<8 & tagrecipe==1
bysort pid: egen tempN=count(ifsa_score_rob3) if level>3 & level<8 & tagrecipe==1
replace temp=temp/tempN
bysort pid: egen Module2Score_rob3=max(temp)
drop tempN

gen Scorediff12_rob2=Module2Score_rob2-Module1Score_rob2
gen Scorediff12_rob3=Module2Score_rob3-Module1Score_rob3

drop temp

cd "$temp"
save Game_data_treated, replace

*Note: The variable Scorediff12 in the file Survey_data comes from this step (use command "keep pid Scorediff12")
*It was already added to the data set Survey_data in the replication package, to allow running the imputation of missing variables separately



*****************************************************************************************************************************************************
*****************************************************************************************************************************************************
*Save Scorediff12 variable used for imputing missing instances of the control variable PriorBehaviors
*****************************************************************************************************************************************************
*****************************************************************************************************************************************************

cd "$temp"
use Game_data_treated, clear
drop if taguser!=1

keep pid Scorediff12

save Scorediff12, replace



*****************************************************************************************************************************************************
*****************************************************************************************************************************************************
*Construction of control variables for PriorKnowledge and PriorBehaviors
*****************************************************************************************************************************************************
*****************************************************************************************************************************************************

cd "$rawdata"
use Survey_data,clear

*merge in Scorediff12 variable used for imputing missing instances of the control variable PriorBehaviors

cd "$temp"
merge 1:1 pid using Scorediff12
drop _merge


********************************************************
*(i) PriorKnowledge: Food safety related knowledge 
*10 questions in the survey that concern food safety related behaviors that are targeted by the information video & game
********************************************************
*reverse code items
foreach y in "Pre" {
gen rFoodPoisPeeling`y'=6-FoodPoisPeeling`y'
gen rFoodPois5sec`y'=6-FoodPois5sec`y'
gen rFoodPoisPinkPatty`y'=6-FoodPoisPinkPatty`y'
gen rFoodPois63degrees`y'=6-FoodPois63degrees`y'
gen rFoodPoisRinseChicken`y'=6-FoodPoisRinseChicken`y'
gen rFoodPoisHandsNoSoap`y'=6-FoodPoisHandsNoSoap`y'

}

*Standardize variables 
local foodposlist "rFoodPoisPeeling FoodPoisRinsing rFoodPois5sec rFoodPoisPinkPatty rFoodPois63degrees rFoodPoisRinseChicken rFoodPoisHandsNoSoap FoodPoisHandsSoap FoodPoisWashTools FoodPoisRinseMelon"


		foreach y of local foodposlist {
		
		sum `y'Pre 
		gen z_`y'Pre=(`y'Pre-r(mean))/r(sd) 
		}

*Define aggregate measure

gen PriorKnowledge=(z_rFoodPoisPeelingPre+z_FoodPoisRinsingPre+z_rFoodPois5secPre+z_rFoodPoisPinkPattyPre+z_rFoodPois63degreesPre+z_rFoodPoisRinseChickenPre +z_rFoodPoisHandsNoSoapPre+z_FoodPoisHandsSoapPre+z_FoodPoisWashToolsPre +z_FoodPoisRinseMelonPre)/10 

********************************************************
*(ii) *PriorBehaviors: Food safety related behaviors
* 22 questions in the surveys that concern food safety related behaviors that are targeted by the information video & game
*standardize responses for behaviors 1 - 4 (frequency of and washing, cleaning cutting boards and kitchen surface, and rinsing raw meat; reversing the response scale on the last item)
*standardize responses for behaviors 5 – 6 (whether a thermometer was used to check if meat was done, any instance of not checking if meat was done; reversing the binary response scale on the latter item) 
*standardize responses for behaviors 7 – 22 (likelihood of rinsing a particular food item before further preparation/consumption; reversing the response scale on rinsing chicken)
*sum all the standardized measures to obtain the aggregate measure of targeted behaviors
********************************************************
local rawbehlistAll "WashHands CleanSurface RinseMeat CleanBoard FoodThermometer NotChecked RinseWholeChicken RinseChickenBreast RinseBeef RinseLettuce RinseWaterMelon RinseApple RinseMango RinseEggplant RinseOnion RinseStringBeans RinseBrusselsSprouts RinsePotatoes RinseCarrots RinseBerries RinseAvocado RinseBeanSprouts"


*reverse code RinseMeatPre
gen rRinseMeatPre=6-RinseMeatPre

*********
** Imputation of missing control variable FoodThermometerPre and NotCheckedPre
* Among "PriorBehaviors", the items FoodThermometerPre and NotCheckedPre are missing for 101 participants because the questions failed to trigger in the survey
*Impute based on basic set of control variables (excluding PriorBehaviors) and the extended set of covariates: 
*********
*Impute FoodThermometerPre when missing: 
logit FoodThermometerPre Scorediff12 Enjoyment SpeedPref HygienePref PriorKnowledge  Age Female Nonbinary SingleHousehold Highschool Vocational Publicsector Privatesector Selfemployed Unemployed Other FreqMeat FreqComputerGames WorkedFoodSector HealthSector HadFoodPoison SharePreprepared Risktolerance InfoSeekPre Children Stressed ConcernedFoodPois KitchenCleanPref AvoidWastePref HygieneMyth 
*Extract coefficients from the logistic regression
matrix b = e(b)
*Calculate predicted probabilities
gen prvals1=   1 / (1 + exp(-(b[1,1] + (b[1,2] * Scorediff12) + (b[1,3] * Enjoyment) + (b[1,4] * SpeedPref) + (b[1,5] * HygienePref) + ///
                 (b[1,6] * PriorKnowledge) + (b[1,7] * Age) + (b[1,8] * Female) + (b[1,9] * Nonbinary) + (b[1,10] * SingleHousehold) + ///
                 (b[1,11] * Highschool) + (b[1,12] * Vocational) + (b[1,13] * Publicsector) + (b[1,14] * Privatesector) + ///
                 (b[1,15] * Selfemployed) + (b[1,16] * Unemployed) + (b[1,17] * Other) + (b[1,18] * FreqMeat) + ///
                 (b[1,19] * FreqComputerGames) + (b[1,20] * WorkedFoodSector) + (b[1,21] * HealthSector) + ///
                 (b[1,22] * HadFoodPoison) + (b[1,23] * SharePreprepared) + (b[1,24] * Risktolerance) + (b[1,25] * InfoSeekPre) + ///
                 (b[1,26] * Children) + (b[1,27] * Stressed) + (b[1,28] * ConcernedFoodPois) + (b[1,29] * KitchenCleanPref) + ///
                 (b[1,30] * AvoidWastePref) + (b[1,31] * HygieneMyth))))
gen FoodThermometerPre_imputed=FoodThermometerPre  
replace FoodThermometerPre_imputed= prvals1 if FoodThermometerPre==.  
*Highschool==1 prefectly predicts FoodThermometerPre=0 in data (hence omitted in logit)
replace FoodThermometerPre_imputed=0 if Highschool == 1
drop prvals1


*Impute NotCheckedPre when missing:
logit NotCheckedPre Scorediff12 Enjoyment SpeedPref HygienePref PriorKnowledge  Age Female Nonbinary SingleHousehold Highschool Vocational Publicsector Privatesector Selfemployed Unemployed Other FreqMeat FreqComputerGames WorkedFoodSector HealthSector HadFoodPoison SharePreprepared Risktolerance InfoSeekPre Children Stressed ConcernedFoodPois KitchenCleanPref AvoidWastePref HygieneMyth 
*Extract coefficients from the logistic regression
matrix b = e(b)
*Calculate predicted probabilities
gen prvals2=   1 / (1 + exp(-(b[1,1] + (b[1,2] * Scorediff12) + (b[1,3] * Enjoyment) + (b[1,4] * SpeedPref) + (b[1,5] * HygienePref) + ///
                 (b[1,6] * PriorKnowledge) + (b[1,7] * Age) + (b[1,8] * Female) + (b[1,9] * Nonbinary) + (b[1,10] * SingleHousehold) + ///
                 (b[1,11] * Highschool) + (b[1,12] * Vocational) + (b[1,13] * Publicsector) + (b[1,14] * Privatesector) + ///
                 (b[1,15] * Selfemployed) + (b[1,16] * Unemployed) + (b[1,17] * Other) + (b[1,18] * FreqMeat) + ///
                 (b[1,19] * FreqComputerGames) + (b[1,20] * WorkedFoodSector) + (b[1,21] * HealthSector) + ///
                 (b[1,22] * HadFoodPoison) + (b[1,23] * SharePreprepared) + (b[1,24] * Risktolerance) + (b[1,25] * InfoSeekPre) + ///
                 (b[1,26] * Children) + (b[1,27] * Stressed) + (b[1,28] * ConcernedFoodPois) + (b[1,29] * KitchenCleanPref) + ///
                 (b[1,30] * AvoidWastePref) + (b[1,31] * HygieneMyth))))
gen NotCheckedPre_imputed=NotCheckedPre  
replace NotCheckedPre_imputed= prvals2 if NotCheckedPre==.  
drop prvals2

gen imputedvalue=0 
replace	imputedvalue=1 if  FoodThermometerPre==. 
replace	imputedvalue=1 if  NotCheckedPre==. 

bysort pid: egen temp=max(imputedvalue)
replace imputedvalue=temp
drop temp


*Fill all rows
drop FoodThermometerPre
bysort pid: egen FoodThermometerPre=max(FoodThermometerPre_imputed)
drop FoodThermometerPre_imputed

drop NotCheckedPre
bysort pid: egen NotCheckedPre=max(NotCheckedPre_imputed)
drop NotCheckedPre_imputed

*reverse code item
gen rNotCheckedPre_imputed=0 
replace rNotCheckedPre_imputed=1 if NotCheckedPre==0 


*reverse code items
gen rRinseWholeChickenPre=12-RinseWholeChickenPre

gen rRinseChickenBreastPre= 12-RinseChickenBreastPre

gen rRinseBeefPre=12-RinseBeefPre


local behlistAll "WashHands CleanSurface rRinseMeat FoodThermometer rNotChecked CleanBoard rRinseWholeChicken rRinseChickenBreast rRinseBeef RinseLettuce RinseWaterMelon RinseApple RinseMango RinseEggplant RinseOnion RinseStringBeans RinseBrusselsSprouts RinsePotatoes RinseCarrots RinseBerries RinseAvocado RinseBeanSprouts"
//quietly{
	foreach y of local behlistAll {
		
		sum `y'Pre 
		gen z_`y'Pre=(`y'Pre-r(mean))/r(sd) 
		}
//}



*Generate summary measures


local looplist "Pre"
foreach y of local looplist {

gen z_behavior1_4`y'=(z_WashHands`y'+z_CleanSurface`y'+z_rRinseMeat`y'+z_CleanBoard`y')/4
gen z_behavior5_6`y'=(z_FoodThermometer`y'+z_rNotChecked`y')/2
gen z_behavior7_22`y'=(z_rRinseWholeChicken`y'+z_rRinseChickenBreast`y'+z_rRinseBeef`y'+z_RinseLettuce`y'+z_RinseWaterMelon`y'+z_RinseApple`y'+z_RinseMango`y'+z_RinseEggplant`y'+z_RinseOnion`y'+z_RinseStringBeans`y'+z_RinseBrusselsSprouts`y'+z_RinsePotatoes`y'+z_RinseCarrots`y'+z_RinseBerries`y'+z_RinseAvocado`y'+z_RinseBeanSprouts`y')/16
gen PriorBehaviors=(4*z_behavior1_4`y'+2*z_behavior5_6`y'+16*z_behavior7_22`y')/22
}


*Drop variables from the survey used to construct the PriorBehavior and PriorKnowledge scores
drop WashHands CleanSurface RinseMeat CleanBoard FoodThermometer* NotChecked RinseWholeChicken RinseChickenBreast RinseBeef RinseLettuce RinseWaterMelon RinseApple RinseMango RinseEggplant RinseOnion RinseStringBeans RinseBrusselsSprouts RinsePotatoes RinseCarrots RinseBerries RinseAvocado RinseBeanSprouts
drop FoodPoisPeeling FoodPoisRinsing FoodPois5sec FoodPoisPinkPatty FoodPois63degrees FoodPoisRinseChicken FoodPoisHandsNoSoap FoodPoisHandsSoap FoodPoisWashTools FoodPoisRinseMelon


drop rFoodPoisPeelingPre	rFoodPois5secPre	rFoodPoisPinkPattyPre	rFoodPois63degreesPre	rFoodPoisRinseChickenPre	rFoodPoisHandsNoSoapPre	z_rFoodPoisPeelingPre	z_FoodPoisRinsingPre	z_rFoodPois5secPre	z_rFoodPoisPinkPattyPre	z_rFoodPois63degreesPre	z_rFoodPoisRinseChickenPre	z_rFoodPoisHandsNoSoapPre	z_FoodPoisHandsSoapPre	z_FoodPoisWashToolsPre	z_FoodPoisRinseMelonPre

drop rRinseMeatPre		rRinseWholeChickenPre	rRinseChickenBreastPre	rRinseBeefPre	z_WashHandsPre	z_CleanSurfacePre	z_rRinseMeatPre	z_CleanBoardPre	z_rRinseWholeChickenPre	z_rRinseChickenBreastPre	z_rRinseBeefPre	z_RinseLettucePre	z_RinseWaterMelonPre	z_RinseApplePre	z_RinseMangoPre	z_RinseEggplantPre	z_RinseOnionPre	z_RinseStringBeansPre	z_RinseBrusselsSproutsPre	z_RinsePotatoesPre	z_RinseCarrotsPre	z_RinseBerriesPre	z_RinseAvocadoPre	z_RinseBeanSproutsPre	

drop rNotCheckedPre z_FoodThermometerPre	z_rNotCheckedPre z_behavior1_4Pre	z_behavior5_6Pre	z_behavior7_22Pre 
cd "$temp"
save Survey_data_treated, replace
*****************************************************************************************************************************************************
*****************************************************************************************************************************************************
*Merge survey and game data to create the work dataset used for the analysis
*****************************************************************************************************************************************************
*****************************************************************************************************************************************************
cd "$temp"
use Survey_data_treated, clear

merge 1:m pid using Game_data_treated
drop _merge


*Treatment indicators (0: Control, 1: Reminder, 2: ManyReminders)
generate treat_R = (treatment==1) //for comparison Reminder vs Control
generate treat_MR = (treatment==2) //for comparison ManyReminders vs Control
gen treat_MRR=treat_MR //for comparison ManyReminders vs Reminder

lab var treat_R         	"Reminder vs. Control"
lab var treat_MR        	"ManyReminders vs. Control"
lab var treat_MRR       	"ManyReminders vs. Reminder"

cd "$input"
save Replicationdata, replace
export delimited using Replicationdata.csv, replace


**********************************




